package com.controller;

import com.service.WechatService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author zhangyan
 * @version $ Id: WechantController.java, v 0.1 2021/11/19 17:05 zhangyan Exp $
 */
@RestController
public class WechatController {

    @Resource
    private WechatService wechatService;

    /**
     * @param request HttpServletRequest
     */
    @GetMapping(value = "/wx")
    public void message(HttpServletRequest request, HttpServletResponse response) throws Exception {
        wechatService.dealMessage(request, response);
    }

    /**
     * post方式是处理用户事件
     */
    @PostMapping(value = "/wx")
    public String access(HttpServletRequest request) {
        String processRequest = wechatService.processRequest(request);
        return processRequest;
    }
}
